package org.datascooter.meta;

import java.io.Serializable;

/**
 * Container for column metadata, received from JDBC driver
 * 
 * @author nemo
 * 
 */
public class Column implements Serializable {

	private static final long serialVersionUID = -5344197053284430721L;
	public final String name;
	public final String dataTypeName;
	public final int scale;
	public final int precision;
	/**
	 * <B>NULLABLE</B> int => is NULL allowed.
	 * <UL>
	 * <LI>columnNoNulls 0- might not allow <code>NULL</code> values</LI>
	 * <LI>columnNullable 1- definitely allows <code>NULL</code> values</LI>
	 * <LI>columnNullableUnknown 2 - nullability unknown</LI>
	 * </UL>
	 */
	private final int isNullable;
	public final Boolean partOfPrimary;

	public Column(String name, String dataTypeName, int scale, int precision, int isNullable, boolean partOfPrimary) {
		this.name = name;
		this.dataTypeName = dataTypeName;
		this.scale = scale;
		this.precision = precision;
		this.isNullable = isNullable;
		this.partOfPrimary = partOfPrimary;
	}

	public Boolean nullable() {
		return isNullable > 0;
	}
}
